<?php $post = $this->get('post'); ?>
<div class="x-list-title">
	<table width="100%" border="0" height="100%">
	<tr>
		<td align="left">
			<h2>Tạo mới cơ hội</h2>
		</td>
		<td align="right">	
			<div class="x-list-options"></div>
		</td>
	</tr>
	</table>	
</div>
<form method="post" action="<?php _actionUrl($this);?>" onsubmit="return ajax_form(this)">
<input type="hidden" name="ID" value="<?php $this->e('ID')?>"/>
<div class="x-form-container">
	<div class="form-message"></div>
	<table width="100%" cellpadding="4" class="x-form">
		<tr>
			<td class="x-form-label" style="width:133px">Mã: </td>
			<td class="x-form-input">
				<input class="x-text" type="text" name="code" value="<?php _e($post['code'])?>" style="width:150px;"/>
			</td>
		</tr>
		
			<tr>
				<td class="x-form-label">Tên cơ hội: </td>
				<td class="x-form-input">
					<input class="x-text" type="text" name="title" value="<?php _e($post['title'])?>" style="width:400px"/>
				</td>
			</tr>
			
			<tr>
				<td class="x-form-label">Ngày bắt đầu: </td>
				<td class="x-form-input">
					<input type="text" name="date_start" value="<?php _e(show_date('d/m/Y',$post['date_start']));?>" onclick="date_picker(this,{format: 'd/m/Y' })" class="x-text x-date"/>
				</td>
			</tr>
			
			<tr>
				<td class="x-form-label">Ngày kết thúc: </td>
				<td class="x-form-input">
					<input type="text" name="date_end" value="<?php _e(show_date('d/m/Y',$post['date_end']));?>" onclick="date_picker(this,{format: 'd/m/Y' })" class="x-text x-date"/>
				</td>
			</tr>			

			<tr>
				<td class="x-form-label">Công ty: </td>
				<td class="x-form-input">
					<?php 
						_e(tpl_auto_select(array(
							name	=>	'customer_id',
							type 	=>  'autosingle',
							url 	=>	baseUrl().'/Crm/Helper/Customer',
							title	=>	'name',
							link 	=> 	'#Crm/Customer/View?ID='
						)));
					?>	
				</td>
			</tr>
			
			<tr>
				<td class="x-form-label">Liên hệ: </td>
				<td class="x-form-input">
					<?php 
						_e(tpl_auto_select(array(
							name	=>	'contact_id',
							type 	=>  'autosingle',
							url 	=>	baseUrl().'/Crm/Helper/Contact',
							title	=>	'title',
							link 	=> 	'#Crm/Contact/View?ID='
						)));
					?>	
				</td>
			</tr>
			
			<tr>
				<td class="x-form-label">Giai đoạn bán hàng: </td>
				<td class="x-form-input">
					<select name="parent_id" class="x-select">
					<?php foreach( $this->get('cats') as $a ):?>
					<option value="<?php _e($a['ID']);?>"<?php if($post['parent_id']==$a['ID']) _e(' selected')?>><?php _e($a['title']);?></option>
					<?php endforeach;?>
					</select>
				</td>
			</tr>

			<tr>
				<td class="x-form-label">Kỳ vọng: </td>
				<td class="x-form-input">
					<input class="x-text" type="text" name="expect" style="width:150px;" value="<?php _e($post['expect']);?>"/>
					<select name="currency_id" class="x-select">
					<?php foreach( $this->get('currencies') as $a ):?>
					<option value="<?php _e($a['ID']);?>"<?php if( $a['ID'] == $post['currency_id'] ) _e(' selected')?>><?php _e($a['title']);?></option>
					<?php endforeach;?>
					</select>					
				</td>
			</tr>
			
			<tr>
				<td class="x-form-label">Xác suất: </td>
				<td class="x-form-input">
					<input size="3" class="x-text x-status" type="text" name="probability" onclick="status_picker(this)" value=""/> %
				</td>
			</tr>			
			
			<tr>
				<td class="x-form-label">Chăm sóc: </td>
				<td class="x-form-input">
					<?php _e(tpl_select_user('care_by_id',''));?>
				</td>
			</tr>

			<tr>
				<td class="x-form-label">Mô tả: </td>
				<td class="x-form-input">
					<textarea class="x-text" name="desc" style="width:500px;height:100px"><?php _e($post['desc']);?></textarea>
				</td>
			</tr>

			<tr>
				<td class="x-form-label" align="center" valign="top">
					<span class="x-attachment"></span>
				</td><!--FILES-->
				<td class="x-form-input" valign="top">
					<div class="x-files" url="<?php _baseUrl();?>/Crm/Opportunity/Upload?post_id=<?php $this->e('ID')?>"></div>
				</td>
			</tr>			
			
			<tr>
				<td></td>
				<td class="x-form-input">
					<input type="submit" value="Cập nhật" class="x-button x-save"/>
					<a href="#Crm/Customer" class="x-button x-fresh">Hủy bỏ</a>
				</td>
			</tr>
	</table>
</div>
</form>